﻿using Volo.Abp.DependencyInjection;
using YAPACS.RisServer.Abstractions;
using YAPACS.Workflows;

namespace YAPACS.RisServer.Workflows.Technician;

public class GetEmergencyRegistView(IDeviceService deviceService) : WorkflowBase, IGetEmergencyRegistView, ITransientDependency
{
    private readonly IDeviceService _deviceService = deviceService;
    protected override async Task<WorkflowOutput> InvokeCoreAsync(WorkflowInput input)
    {
        WorkflowOutput workflowOutput = new()
        {
            Success = true,
            ViewTitle = "绿色通道",
            NextAction = "技师-紧急登记",
            NextActionCaption = "新建",
            ViewWidth = "50%"
        };
        var device = await _deviceService.GetDeviceIfOnlyOneAsync();
        if (device != null)
        {
            workflowOutput.Data = new
            {
                ExamDevice = device.Oid
            };
        }
        //返回一个默认的amis form表单
        workflowOutput.View = await Extensions.GetResourceStringAsync("Resources.Technician.emergency-register.json");
        return workflowOutput;
    }
}
